function validateRegistration() {
	var fname = document.forms["register"]["fname"].value;
	var lname = document.forms["register"]["lname"].value;
	var pass = document.forms["register"]["password"].value;
	var length = pass.length;
	var letters = /^[A-Za-z]+$/;
	if (fname == null || fname == "" || lname == null || lname == "" || pass == null || pass == "") {
		alert("Error: One or more of the fields are missing. Please try again.");
		if (fname == null || fname == "") {
			document.getElementById("fname").style.background='crimson';
			document.getElementById("first").style.color='white';
		}
		if (lname == null || lname == "") {
			document.getElementById("lname").style.background='crimson';
			document.getElementById("last").style.color='white';
		}
		if (pass == null || pass == "") {
			document.getElementById("password").style.background='crimson';
			document.getElementById("pass").style.color='white';
		}
		return false;
	}
	else  {
		if (length < 6) {
			alert("Error: Password is not long enough. Please try again.");
			document.getElementById("password").style.background='crimson';
			document.getElementById("pass").style.color='white';
			return false;
		}
		else {
			if (!fname.match(letters) || !lname.match(letters)) {
				alert("Error: First Name and Last Name fields must be letters only.");
				if (!fname.match(letters)) {
					document.getElementById("fname").style.background='crimson';
					document.getElementById("first").style.color='white';
				}
				if (!lname.match(letters)) {
					document.getElementById("lname").style.background='crimson';
					document.getElementById("last").style.color='white';
				}
				return false;
			}
		}
	}
}
function changeLname() {
	document.getElementById("lname").style.background='white';
	document.getElementById("last").style.color='#47433F';
}
function changeFname() {
	document.getElementById("fname").style.background='white';
	document.getElementById("first").style.color='#47433F';
}
function changePassword() {
	document.getElementById("password").style.background='white';
	document.getElementById("pass").style.color='#47433F';
}
function print(id) {
	window.open("print.php?id="+id,"print","fullscreen");
	window.focus();
	return true;
}
function logout() {
	var x=confirm("Are you sure you want to logout?");
	if(x) {
		alert('Thank you for using the BDPA-NY Vending Machine Application! Please come back soon!');
		window.location='logout.php';
	}
	else {
		alert('Keep browsing through the application!');
	}
}